// var webpack = require('webpack');
// var HtmlwebpackPlugin = require('html-webpack-plugin');
// var ExtractTextPlugin = require('extract-text-webpack-plugin');

// var helpers = require('./helpers');

// module.exports = {
//     entry: {
//         'polyfills': './src/polyfills.ts', //浏览器运行angular的标准填充物 
//         'vendor': './src/vendor.ts', //提供商文件 比如Angular Lodash bootstrap
//         'app': './src/main.ts' //我们的应用代码  
//     },
//     resolve: {
//         extensions: ['', '.ts', '.js']
//     },
//     module: {
//         loaders: [
//             {
//                 test: /\.ts$/,
//                 loaders: ['awesome-typescript-loader', 'angular2-template-loader']
//             },
//             {
//                 test: /\.html$/,
//                 loader: 'html'
//             },
//             {
//                 test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
//                 loader: 'file?name=assets/[name].[hash].[ext]'
//             },
//             {
//                 test: /\.css$/,
//                 exclude: helpers.root('src', 'app'),
//                 loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
//             },
//             {
//                 test: /\.css$/,
//                 include: helpers.root('src', 'app'),
//                 loader: 'raw'
//             }
//         ]
//     },
//     plugins: [
//         new webpack.optimize.CommonsChunkPlugin({
//             name: ['app', 'vendor', 'polyfills']
//         }),

//         new HtmlWebpackPlugin({
//             template: 'src/index.html'
//         })
//     ]
// }

var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');

module.exports = {
  entry: {
    'polyfills': './src/polyfills.ts',
    'vendor': './src/vendor.ts',
    'app': './src/main.ts'
  },

  resolve: {
    extensions: ['', '.ts', '.js']
  },

  module: {
    loaders: [
      {
        test: /\.ts$/,
        loaders: ['awesome-typescript-loader', 'angular2-template-loader']
      },
      {
        test: /\.html$/,
        loader: 'html'
      },
      {
        test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
        loader: 'file?name=assets/[name].[hash].[ext]'
      },
      {
        test: /\.css$/,
        exclude: helpers.root('src', 'app'),
        loader: ExtractTextPlugin.extract('style', 'css?sourceMap')
      },
      {
        test: /\.css$/,
        include: helpers.root('src', 'app'),
        loader: 'raw'
      }
    ]
  },

  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      name: ['app', 'vendor', 'polyfills']
    }),

    new HtmlWebpackPlugin({
      template: 'src/index.html'
    })
  ]
};

